//
//  SMHTeamSectionView.swift
//  SMHCommerce
//
//  Created by lvzhao on 2020/6/1.
//  Copyright © 2020 lvzhao. All rights reserved.
//

import UIKit

class SMHTeamSectionView: LZBaseView {
    
    var imageView = UIImageView()
    var viewModel = SMHTeamViewModel()

    var idx : Int = -1
    
    convenience init(viewModel: LZBaseViewModel, index:Int) {
        self.init(viewModel: viewModel)
        
        idx = index
        self.backgroundColor = UIColor.white
        setupUI()
    }
    
    override init(viewModel: LZBaseViewModel) {
        super.init(viewModel: viewModel)
        self.viewModel = viewModel as! SMHTeamViewModel
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK:setupUI
    func setupUI() {
        
        self.addSubview(self.flodBtn)
        self.flodBtn.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.top.equalTo(0)
            make.width.equalTo(kScreenWidth - 30)
            make.height.equalTo(50)
        }
        
        self.flodBtn .layoutButtonEdgeInsets(style: .ButtonEdgeInsetsStyleLeft, space: 7)

        //MARK:展示动画
        updateImageView(isCheck: self.viewModel.indexs.contains(self.idx))
        
       
    
        let lineView = UIView()
        lineView.backgroundColor = UIColorFromHex(rgbValue: 0xE5E5E5)
        self.addSubview(lineView);
        lineView.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.bottom.equalTo(0)
            make.width.equalTo(kScreenWidth - 30)
            make.height.equalTo(0.5)
        }
    }
    
    func updateImageView(isCheck:Bool){
        if(isCheck){
            self.flodBtn.setImage(UIImage(named: "icon_ware_fold_select"), for: .normal)
        } else {
            self.flodBtn.setImage(UIImage(named: "icon_ware_fold_nor"), for: .normal)
        }
    }
    
    
    lazy var flodBtn : UIButton = {
        let flodBtn = UIButton()
        flodBtn.setTitle("销售公司(100)", for: .normal)
        flodBtn.setTitleColor(UIColorFromHex(rgbValue: 0x363636), for: .normal)
        flodBtn.setImage(UIImage(named: "icon_ware_fold_nor"), for: .normal)
        flodBtn.contentHorizontalAlignment = .left
        flodBtn.titleLabel?.font = ktextFont(size: 15)
        return flodBtn
    }()
    

    

}
